fix: plugin tooltip window size can adapt to content changes#357
Merged
deepin-bot[bot] merged 1 commit intoAug 28, 2025
Merged
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideAdds early exits to skip redundant updates when tooltip content is unchanged and triggers parent widget size adjustments after resizing to ensure the tooltip window adapts to content changes. Sequence diagram for tooltip content update and window resizesequenceDiagram
participant App
participant TipsWidget
participant ParentWidget
App->>TipsWidget: setText(newText)
TipsWidget->>TipsWidget: Check if m_text == newText
alt Text unchanged
TipsWidget-->>App: Return (no update)
else Text changed
TipsWidget->>TipsWidget: Update m_text
TipsWidget->>TipsWidget: setFixedSize(...)
TipsWidget->>ParentWidget: adjustSize()
TipsWidget->>TipsWidget: update()
end
Class diagram for updated TipsWidget methodsclassDiagram
class TipsWidget {
- QString m_text
- QStringList m_textList
setText(QString text)
setTextList(QStringList textList)
}
TipsWidget : setText() updated to skip redundant updates and adjust parent size
TipsWidget : setTextList() updated to skip redundant updates and adjust parent size
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
5387812 to
1625268
Compare
18202781743
approved these changes
Aug 28, 2025
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 18202781743, yixinshark The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
as title Log: as title Pms: BUG-290591
1625268 to
109f1e7
Compare
deepin pr auto review这段代码是关于 TipsWidget 类的两个方法:setText 和 setTextList 的修改。我来对这段代码进行审查,并提出改进意见。 1. 语法逻辑优点:
改进建议:
2. 代码质量优点:
改进建议:
3. 代码性能优点:
改进建议:
4. 代码安全优点:
改进建议:
具体改进建议代码示例:void TipsWidget::setText(const QString &text)
{
if (text.isEmpty()) {
return;
}
QTextDocument document;
document.setHtml(text);
QString newText = document.toPlainText().simplified();
if (m_text == newText) {
return;
}
m_text = newText;
// 调整尺寸
adjustWidgetSize();
update();
}
void TipsWidget::setTextList(const QStringList &textList)
{
if (textList.isEmpty()) {
return;
}
m_type = TipsWidget::MultiLine;
if (textList == m_textList) {
return;
}
m_textList = textList;
// 调整尺寸
adjustWidgetSize();
update();
}
void TipsWidget::adjustWidgetSize()
{
if (m_type == SingleLine) {
setFixedSize(fontMetrics().horizontalAdvance(m_text),
fontMetrics().boundingRect(m_text).height());
} else {
int width = 0;
int height = 0;
for (const QString &text : m_textList) {
QSize textSize = fontMetrics().boundingRect(text).size();
width = qMax(width, textSize.width());
height += textSize.height();
}
setFixedSize(width, height);
}
if (parentWidget()) {
parentWidget()->adjustSize();
}
}这个改进版本提取了调整尺寸的逻辑到单独的方法中,减少了重复代码,并添加了对输入参数的验证。同时,保持了原有的性能优化和安全检查。 |
Contributor
Author
|
/forcemerge |
|
This pr force merged! (status: blocked) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
as title
Log: as title
Pms: BUG-290591
Summary by Sourcery
Detect content changes in TipsWidget and dynamically adjust its and its parent’s size when tooltip text or text list is updated.
Bug Fixes:
Enhancements: